# 批量实现 txt 文件的文本的合并
import os

data_dir = "../manytxt"
content = []
for file in os.listdir(data_dir):
    file_path = f"{data_dir}/{file}"
    print(file_path)
    if os.path.isfile(file_path) and file_path.endswith(".txt"):
        with open(file_path, "r", encoding="utf-8") as content_file:
            content.append(content_file.read())
            print(content)

final_content = "\n".join(content)

with open("../manytxt.txt", "w", encoding="utf-8") as many_file:
    many_file.write(final_content)
